<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="rich" uri="http://richfaces.org/rich"%>
<%@ taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<c:if test="${mbConnexion.login != true }">
	<jsp:forward page="connection.jsp" /></c:if>
<f:view>
	<a4j:form>
		<h:panelGrid columns="1" styleClass="wrapper">
			<h:outputLabel value="Recherche Medecin" styleClass="title"
				for="name" />
			<h:panelGroup>
				<h:panelGrid columns="2">
					<h:inputText id="medecin" value="#{mbAcceuil.saisieMedecin}"
						styleClass="textBox" size="50" />
					<a4j:commandButton action="#{mbAcceuil.rechercheMedecin}" reRender="tabMedecin" value="Recherche" styleClass="testButton"
						style="testButton fontBackgroundColor"></a4j:commandButton>
				</h:panelGrid>
				<rich:suggestionbox id="suggestionBoxId" for="medecin"
					suggestionAction="#{mbAcceuil.autoCompleteMedecin}" var="result"
					tokens="," height="150" width="160" cellpadding="2" cellspacing="2"
					shadowOpacity="4" shadowDepth="4" minChars="1" rules="none"
					nothingLabel="No se encontro nada">
					<h:column>
						<h:outputText value="#{result}" style="font-style:bold" />
					</h:column>
				</rich:suggestionbox>
			</h:panelGroup>
		</h:panelGrid>


		<rich:panel>
		<a4j:outputPanel id="tabMedecin">
			<rich:dataTable rendered="#{not empty  mbAcceuil.listMedecin}"
				value="#{mbAcceuil.listMedecin }" var="medecin">
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Nom" style="text-align:left;"></h:outputText>
					</f:facet>
					<h:outputText value="#{medecin.nom }"></h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Prenom" style="text-align:left;"></h:outputText>
					</f:facet>
					<h:outputText value="#{medecin.prenom }"></h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">
						<h:outputText value="poste" style="text-align:left;"></h:outputText>
					</f:facet>
					<h:outputText value="#{medecin.telephone }"></h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Evenements" style="text-align:left;"></h:outputText>
					</f:facet>
					<a4j:commandLink reRender="evenements"
						actionListener="#{mbAcceuil.afficherEvenementByIdMedecin}"
						value="Evenements">
						<f:attribute value="#{medecin.idMedecin}" name="idMedecin" />
					</a4j:commandLink>
						&nbsp;
					<a4j:commandLink action="#{mbRdv.redirectRdv }" value="Ajouter un Rdv">
						<f:param binding="#{mbRdv.idMedecin }" value="#{medecin.idMedecin }" name="idMed"></f:param>
					</a4j:commandLink>
				</rich:column>
			</rich:dataTable>
		</a4j:outputPanel>
		</rich:panel>
		<rich:panel>
			<a4j:outputPanel id="evenements">
				<rich:dataTable rendered="#{not empty  mbAcceuil.listEvenement}"
					value="#{mbAcceuil.listEvenement }" var="evenement">
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Date" style="text-align:left;"></h:outputText>
						</f:facet>
						<h:outputText value="#{evenement.dateEvenement }"></h:outputText>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Heure de debut" style="text-align:left;"></h:outputText>
						</f:facet>
						<h:outputText value="#{evenement.heureDebut }"></h:outputText>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Heure de fin" style="text-align:left;"></h:outputText>
						</f:facet>
						<h:outputText value="#{evenement.heureFin }"></h:outputText>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="patient" style="text-align:left;"></h:outputText>
						</f:facet>
						<h:outputText value="#{evenement.patient.nom }"></h:outputText>
						&nbsp;
						<h:outputText value="#{evenement.patient.prenom }"></h:outputText>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="modifier" style="text-align:left;"></h:outputText>
						</f:facet>
						<a4j:commandLink action="#{mbAcceuil.afficherEvenementById }" value="Modifier un evenement" reRender="tabEvenementModif">
							<f:attribute value="#{evenement.idEvenement }" name="idEvenement"/> 
							<f:param binding="#{mbAcceuil.idEvenement}" value="#{evenement.idEvenement }" name="idEv"></f:param> 
						</a4j:commandLink>
					</rich:column>
				</rich:dataTable>
			</a4j:outputPanel>
		</rich:panel>
		
		
					<rich:panel>
						<a4j:outputPanel id="tabEvenementModif">
							<rich:dataTable rendered="#{mbAcceuil.evenement != null}" value="#{mbAcceuil.evenement}" var="evenement">
								<rich:column>
									<f:facet name="header">
									<h:outputText value="Id" style="text-align:left;"></h:outputText>
									</f:facet>
									<h:outputText value="#{evenement.idEvenement}" />
								</rich:column>
								<rich:column>
									<f:facet name="header">
									<h:outputText value="Date" style="text-align:left;"></h:outputText>
									</f:facet>
									<rich:calendar value="#{evenement.dateEvenement}" datePattern="yyyy-MM-dd"/>
								</rich:column>
								<rich:column>
									<f:facet name="header">
									<h:outputText value="Heure de debut" style="text-align:left;"></h:outputText>
									</f:facet>
									<h:inputText value="#{evenement.heureDebut}"/>
								</rich:column>
								<rich:column>
									<f:facet name="header">
										<h:outputText value="Heure de fin" style="text-align:left;"></h:outputText>
									</f:facet>
									<h:inputText value="#{evenement.heureFin}"/>
								</rich:column>
								<rich:column>
									<f:facet name="header">
										<h:outputText value="patient" style="text-align:left;"></h:outputText>
									</f:facet>
									<h:outputText value="#{evenement.patient.nom}"/>
									&nbsp
									<h:outputText value="#{evenement.patient.prenom}"/>
								</rich:column>
								<rich:column>
									<f:facet name="header">
										<h:outputText value="valider" style="text-align:left;"></h:outputText>
									</f:facet>
									<a4j:commandButton action="#{mbAcceuil.updateEvenement}" reRender="evenements" value="Modifier" styleClass="testButton"style="testButton fontBackgroundColor"></a4j:commandButton>
								</rich:column>
				</rich:dataTable>
			</a4j:outputPanel>
		</rich:panel>
	</a4j:form>
	</f:view>
</body>
</html>